<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><spring:message code="message.lable.compdrugprofileStd"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %> 
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">

    <section class="content-header">
        <h1><spring:message code="message.lable.profileSeeStd"/></h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.StdManage"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.compdrugprofileStd"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.profileSeeStd"/></a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                    <div class="input">
                    <div class="textalign1"><spring:message code="message.listForm.tongYongMing"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="qualityspecName" name="qualityspecName" type="text" placeholder="<spring:message code="message.listForm.tongYongMing"/>" />
                    </div>
                    <div class="textalign1"><spring:message code="message.listForm.yaoPinBianMa"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="drugcode" name="drugcode" type="text" placeholder="<spring:message code="message.listForm.yaoPinBianMa"/>" />
                    </div>
           			
                    <div class="textalign1"><spring:message code="message.lable.status"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                       <select id="status" name="status" class="textinput">
                           	<option value="" ><spring:message code="message.select.option"/></option>
                            <option value="1" ><spring:message code="message.button.start"/></option>
                            <option value="2"><spring:message code="message.button.stop"/></option>
                            <option value="3"><spring:message code="message.button.combine"/></option>
                           </select>
                     </div>
                     <div class="textalign1" >
                    <button id="selectDrug" type="button" onclick="gridSerch();" class="btn btn-success btn-sm"><spring:message code="message.button.seachSpacing"/></button>
               		</div>
                </div>
            </div>
        </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %> 
    <script type="text/javascript">
    
  //绑定回车
    $('#drugcode,#qualityspecName,#status').bind('keydown', function(event) {
        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
            $('#selectDrug').click();
        }
    }); 
  
    $("#qualityspecName").focus();//加载页面光标在第一个查询框内
        
        $(function () {
            
            $("#gridlist").jqGrid({
                url: "${ctx}/stdProdDrugInfo/getStdProdDrugInfoList.html",
                mtype: "POST",
                datatype: "json",
                autowidth: true,
                height: 300,
                colNames: [ 
                            '<spring:message code="message.jqGrid.cz"/>', 
                            'prodId',
                            'qualityspecId',
                            '<spring:message code="message.listForm.yaoPinBianMa"/>', 
                            '<spring:message code="message.listForm.tongYongMing"/>',
                            '<spring:message code="message.listForm.jiXing"/>', 
                            '<spring:message code="message.listForm.guiGe"/>', 
                            '<spring:message code="message.listForm.zhuanHuanXiShu"/>',
                            '<spring:message code="message.listForm.baoZhuangDanWei"/>',
                            '<spring:message code="message.listForm.caiZhi"/>', 
                            '<spring:message code="message.listForm.shengChanQiYe"/>', 
                            '<spring:message code="message.lable.zhuangTai"/>' 
                            ],
                colModel: [
					{ name: 'operate', width: 50, align: "center",sortable: false, 
					    formatter : function(val, opts, rowdata) {
					        var str = "";
					        str +="<ms:btn url='/compDrugProfile/toCompDrugProfileList.html'><a href='${ctx}/compDrugProfile/toCompDrugProfileList.html?prodId="+rowdata.prodId+"&compId=" + rowdata.compId + "' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -40px -20px' class='opIcon' title='<spring:message code=""/><spring:message code="message.jqGrid.cz.qualificationManagement"/>'></a></ms:btn>";
					        return str;
					    }
					},
                    { name: 'prodId', width: 120 ,hidden:true, align:"center",sortable: false},
                    { name: 'qualityspecId',hidden:true, width: 120 , align:"center",sortable: false},
                    { name: 'drugCode', width: 120 , align:"center",sortable: false},
                    { name: 'qualityspecName', width: 180 , align:"left" ,sortable: false},
                    { name: 'formName', width: 80 , align:"center" ,sortable: false},
                    { name: 'specName', width: 80 , align:"left" ,sortable: false},
                    { name: 'factor', width: 80 , align:"center" ,sortable: false},
                    { name: 'unitName', width: 80 , align:"center" ,sortable: false},
                    { name: 'materialName', width: 80 , align:"center" ,sortable: false},
                    { name: 'compName', width: 180 , align:"left",sortable: false,
                        formatter:function(cellvalue, options, row){
                            return '<a href="javascript:showCompInfo(\''+ row.compId +'\');">'+(cellvalue || '')+'</a>';
                        }
                    },
                    { name: 'status', width: 80 , align:"center",sortable: false,
                    	formatter:function(cellvalue, options, row){
                            if (cellvalue == 1) {
                                return "<spring:message code='message.button.start'/>";
                            } else if (cellvalue == 3) {
                                return "<spring:message code='message.button.combine'/>";
                            }
                            return "<span class='red'><spring:message code='message.button.stop'/></span>";
                        }
                    }
                ],
                rowNum: 20,
                rowList: [10,20,50,100],
                rownumbers: true,
                pager: "#gridpage",
                multiselect: false, 
                viewrecords: true,
                caption: "<spring:message code='message.list.compdrugprofileStdlist'/>",
                jsonReader: {
                    repeatitems: false,
                    id: "prodId"
                },
                gridComplete:function(){
                    //序号列宽度自适应（参数为jqgridID）
                    autoRNWidth("gridlist");
                    //数据只有一条时默认选中（参数为jqgridID）
                    selectByOneData("gridlist");
                },
                /* gridComplete:function(){        
                    var page = $("#gridlist").jqGrid('getGridParam','page');
                    var rows = $('#gridlist').getGridParam("rowNum");
                    var maxnum = (rows*page).toString();
                    var len = (maxnum.length)*10;
                    $('.jqgfirstrow').find('td').eq(0).css('width',len+'px');
                    $('#gridlist_rn').css('width',len+'px');
                } */
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");  
            
        });

        //查询
        function gridSerch() {
            var drugcode = $("#drugcode").val();
            var qualityspecName = $("#qualityspecName").val();
            var prodCompName = $("#prodCompName").val();
            var status = $("#status").val();
            $("#gridlist").jqGrid('setGridParam',{  
                datatype:'json',
                postData:{
                    "drugCode":drugcode,
                    "qualityspecName":qualityspecName,
                    "prodCompName":prodCompName,
                    "status":status
                }
            }).trigger("reloadGrid"); //重新载入  
        }
        
        //生产企业弹窗
        function showCompInfo(prodCompId) {
            $.HN.dialog.open({
                "id": "showCompInfo", 
                "title": "<spring:message code='message.listForm.shengChanQiYe'/><spring:message code='message.listForm.xinXi'/>", 
                "url": "${ctx}/stdCompinfo/toStdCompinfoDetail.html?compId="+prodCompId,
                "data": {}, 
                "width": 800, 
                "height": 400, 
                "closefunc":function() {
                    
                }
            });
        }
        
    </script>
</body>
</html>